package com.gxuwz.medical.domain.chronicinfo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Date;

import com.gxuwz.medical.database.DbUtil;
import com.gxuwz.medical.tools.DateUtil;

public class Reducttreat {
private Integer id;
private String chronicInfoId;
private String treattime;
private Integer money;
private String hosId;
private Integer reductstatus;
private Integer freemoney;
private ChronicInfo chronicInfo;
public Integer getId() {
	return id;
}
public void setId(Integer id) {
	this.id = id;
}
public String getChronicInfoId() {
	return chronicInfoId;
}
public void setChronicInfoId(String chronicInfoId) {
	this.chronicInfoId = chronicInfoId;
}
public String getTreattime() {
	return treattime;
}
public void setTreattime(String treattime) {
	this.treattime = treattime;
}
public Integer getMoney() {
	return money;
}
public void setMoney(Integer money) {
	this.money = money;
}
public String getHosId() {
	return hosId;
}
public void setHosId(String hosId) {
	this.hosId = hosId;
}

public Integer getReductstatus() {
	return reductstatus;
}
public void setReductstatus(Integer reductstatus) {
	this.reductstatus = reductstatus;
}
public Integer getFreemoney() {
	return freemoney;
}
public void setFreemoney(Integer freemoney) {
	this.freemoney = freemoney;
}
public ChronicInfo getChronicInfo() {
	return chronicInfo;
}
public void setChronicInfo(ChronicInfo chronicInfo) {
	this.chronicInfo = chronicInfo;
}
public void addReducttreat()throws Exception{
	Connection conn=null;
	try{
		
		conn=DbUtil.getConn();
	    //2:持久化数据
		saveToDB(conn);
	}catch(Exception e){
		e.printStackTrace();
		throw e;
	}finally{
		//关闭连接
		DbUtil.close(conn);
	}
	
	
}
private void saveToDB(Connection conn)throws SQLException{

	  PreparedStatement pstmt=null;
	  try{
		  StringBuffer sqlBuff=new StringBuffer("INSERT INTO t_reducttreat (chronicInfoId, treattime, money, hosId,reductstatus,freemoney)");
		  			   sqlBuff.append("VALUES (?, ?, ?, ?,?,?)");
		  pstmt=conn.prepareStatement(sqlBuff.toString());
		  int index=1;
		  pstmt.setString(index++, this.chronicInfoId);
		  pstmt.setString(index++, this.treattime);
		  pstmt.setInt(index++, this.money);
		  pstmt.setString(index++, this.hosId);
		  pstmt.setInt(index++, this.reductstatus);
		  pstmt.setInt(index++, this.freemoney);
		  int count =pstmt.executeUpdate(); 
	  }catch(SQLException e){
		  e.printStackTrace();
		  throw e;
	  }finally{
		  DbUtil.close(pstmt);
	  } 
}


}
